<?php

$url = explode("/", $_SERVER['HTTP_REFERER']);
if (strcmp($url[count($url) - 1], 'submit.php') != 0) {
  header("Location: submit.php");
}

session_start();

if ( isset($_SESSION['username']) )                     { $username                     = $_SESSION['username']; }
if ( isset($_SESSION['affiliation']) )                  { $affiliation                  = $_SESSION['affiliation']; }
if ( isset($_SESSION['title']) )                        { $title                        = $_SESSION['title']; }
if ( isset($_SESSION['telephone']) )                    { $telephone                    = $_SESSION['telephone']; }
if ( isset($_SESSION['email']) )                        { $email                        = $_SESSION['email']; }
if ( isset($_SESSION['division']) )                     { $division                     = $_SESSION['division']; }
if ( isset($_SESSION['other_division']) )               { $other_division               = $_SESSION['other_division']; }
if ( isset($_SESSION['presentation_type']) )            { $presentation_type            = $_SESSION['presentation_type']; }
if ( isset($_SESSION['equipment']) )                    { $equipment                    = $_SESSION['equipment']; }
if ( isset($_SESSION['other_equipment']) )              { $other_equipment              = $_SESSION['other_equipment']; }
if ( isset($_SESSION['abstract_title']) )               { $abstract_title               = $_SESSION['abstract_title']; }
if ( isset($_SESSION['abstract_author_names']) )        { $abstract_author_names        = $_SESSION['abstract_author_names']; }
if ( isset($_SESSION['abstract_author_affiliations']) ) { $abstract_author_affiliations = $_SESSION['abstract_author_affiliations']; }
if ( isset($_SESSION['abstract']) )                     { $abstract                     = $_SESSION['abstract']; }
if ( isset($_SESSION['abstract_keywords']) )            { $abstract_keywords            = $_SESSION['abstract_keywords']; }

if ( isset($_SESSION['symposium_total_titles']) )              { $symposium_total_titles              = $_SESSION['symposium_total_titles']; }
if ( isset($_SESSION['symposium_total_author_names']) )        { $symposium_total_author_names        = $_SESSION['symposium_total_author_names']; }
if ( isset($_SESSION['symposium_total_author_affiliations']) ) { $symposium_total_author_affiliations = $_SESSION['symposium_total_author_affiliations']; }
if ( isset($_SESSION['symposium_total_keywords']) )            { $symposium_total_keywords            = $_SESSION['symposium_total_keywords']; }

session_unset();
session_destroy();

$_SESSION = array();

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  <link rel="stylesheet" href="style.css" type="text/css" />
  <title>第四十八屆台灣心理學年會投稿系統</title>
</head>

<body>
  <div id="container">
    <div id="header">
      <h1>投稿<span class="h1_span">成功</span></h1>
    </div>

    <h2>投稿成功！確認信將寄送到 <?php echo $email ?></h2>

    <h3>您填寫資訊如下：</h3>

    <div>
      <fieldset>
      <legend>個人資訊</legend>
        <ul>
			  <li>姓名：<?php echo $username ?></li>
		  	<li>單位：<?php echo $affiliation ?></li>
			  <li>職稱：<?php echo $title ?></li>
			  <li>聯絡電話：<?php echo $telephone ?></li>
			  <li>電子郵件：<?php echo $email ?></li>
			  <li>參加組別：
        <?php
          if (strcmp($division, 'other') == 0) {
            echo "$other_division";
          }
          else {
            if (strcmp($division, 'cognitive') == 0) { echo '認知'; }
            if (strcmp($division, 'educational') == 0) { echo '教心'; }
            if (strcmp($division, 'io') == 0) { echo '工商'; }
            if (strcmp($division, 'social') == 0) { echo '社心人格'; }
            if (strcmp($division, 'clinical') == 0) { echo '臨床諮商'; }
            if (strcmp($division, 'psychometric') == 0) { echo '計量'; }
            if (strcmp($division, 'developmental') == 0) { echo '發展'; }
            if (strcmp($division, 'biological') == 0) { echo '生心'; }
          }
        ?>
        </li>
		    </ul>
      </fieldset>
      <fieldset>
      <legend>投稿資訊</legend>
        <ul>
			  <li>投稿類別：
        <?php
          if (strcmp($presentation_type, "symposium") == 0) { echo '專題座談'; }
          if (strcmp($presentation_type, "oral") == 0) { echo '口頭報告'; }
          if (strcmp($presentation_type, "poster") == 0) { echo '壁報'; }
        ?>
        </li>
		  	<li>所需器材：
        <?php
          if (strcmp($equipment, '') == 0) {
            echo '不需要';
          }
          else {
            $selected_equipment = explode(",", $equipment);
            if (count($selected_equipment) == 2) {
              echo '簡報筆 及 ' . $other_equipment;
            }
            else {
              if (strcmp($selected_equipment[0], 'laser_pen') == 0) {
                echo "簡報筆";
              }
              else {
                echo $other_equipment;
              }
            }
          }
        ?>
        </li>
		    </ul>
      </fieldset>
      <fieldset>
      <legend>論文資訊</legend>
        <ul>
        <?php
          if (strcmp($presentation_type, 'symposium') != 0) {
		  	    echo "<li>題目：" . $abstract_title . "</li>
                  <li>作者：" . str_replace('@@', ', ', $abstract_author_names) . "</li>
		  	          <li>所屬單位：" . str_replace('@@', ', ', $abstract_author_affiliations) . "</li>
		  	          <li>摘要：不列出</li>
		  	          <li>關鍵字：" . $abstract_keywords . "</li>";
          }
          else {
            $symposium_total_author_names = str_replace('@@', ', ', $symposium_total_author_names);
            $symposium_total_author_affiliations = str_replace('@@', ', ', $symposium_total_author_affiliations);
		  	    echo "<li>題目：<br /><ul><li>" . str_replace('~~', '</li><li>', $symposium_total_titles) . "</ul></li>
                  <li>作者：<br /><ul><li>" . str_replace('~~', '</li><li>', $symposium_total_author_names) . "</ul></li>
		  	          <li>所屬單位：<br /><ul><li>" . str_replace('~~', '</li><li>', $symposium_total_author_affiliations) . "</ul></li>
		  	          <li>摘要：不列出</li>
		  	          <li>關鍵字：<br /><ul><li>" . str_replace('~~', '</li><li>', $symposium_total_keywords) . "</ul></li>";
          }
        ?>
        </ul>
      </fieldset>
    </div>

    <div id="footer">
      <p>&copy; 2009 第四十八屆台灣心理學年會</p>
    </div>

  </div>
</body>
</html>